#include "GameOverScene.h"
USING_NS_CC;

Scene* GameOverScene::createScene()
{
    auto scene = Scene::create();
    auto layer = GameOverScene::create();
    scene->addChild(layer);
    return scene;
}
bool GameOverScene::init()
{   
    if ( !Layer::init() ) return false;   

#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
	auto uiResultScreen = (Layout*)(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("gfx/result_screen.json"));
#else
	auto uiResultScreen = (Layout*)(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("result_screen.json"));
#endif
	uiResultScreen->setScale(SCALE_X,SCALE_Y);
	this->addChild(uiResultScreen, ZINDEX_GOBACKGROUND);

	auto btn_playAgain = (Button*)(uiResultScreen->getChildByName("btn_playAgain"));
	btn_playAgain->addTouchEventListener(this, toucheventselector(GameOverScene::gotoGamePlay));

}
void GameOverScene::gotoGamePlay(Ref* pSender, TouchEventType type)
{
	if(type == TouchEventType::TOUCH_EVENT_ENDED)
	{
		Director::getInstance()->replaceScene(GamePlayScene::createScene());
	}
}